import { DvaInstance, Model } from 'dva-core';
import { History } from 'history';
import { WxApp } from '@/interfaces';
import { DvaOption } from '../dva';

export type ILoadModelFun = (m: string) => Promise<any>;

export interface IRouterConfigProps {
  history: History;
  app: ICreateDvaAppInstance;
  fallbackRoute?: History.LocationDescriptor;
}

export interface ICreateDvaAppInstance extends DvaInstance {
  history: History;

  setupModels(): void;

  getModels(): Model[];
}

export interface ICreateDvaAppOptions {
  dvaOptions?: DvaOption;
  loadModel: ILoadModelFun | null;
  routes: WxApp.RouteObject[];
  publicModels: string[];
  hooks?: Function[];
  root?: (ele: React.ReactNode) => React.ReactNode;
}

export interface IBuildAppOptions extends Omit<ICreateDvaAppOptions, 'page'> {
  selector: string | HTMLElement;
}
